<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    
    <script src="./js/KPromise.js"></script>

    <script>

        // setTimeout(_=>{
        //     console.log('setTimeout');
        // }, 0);

        // new KPromise((resolve) => {
        //     resolve();
        // }).then(_=>{
        //     console.log('then');
        // });
    
        let p1 = new KPromise( (resolve, reject) => {
            // setTimeout(_=>{
            //     console.log('KPromise');

            //     // resolve();
            //     reject();
            // }, 1000);

            console.log('KPromise');
            resolve('开课吧');
        } );

        // p1.then(val => {
        //     console.log('val', val);
        // }, err => {
        //     console.log('err', err);
        // });
        // p1.then(val => {
        //     console.log('val2', val);
        // }, err => {
        //     console.log('err2', err);
        // });

        let p2 = p1.then(val => {
            console.log('开课吧', val);
            // return 123;
            return new KPromise( (resolve, reject) => {
                setTimeout(_=>{
                    console.log('setTimeout2');
                    resolve('kaikeba')
                }, 1000);
            } );
        })
        p2.then(val => {
            console.log('开课吧1', val);
            return 123;
        }).then(val => {
            console.log('3', val);
            return new KPromise(resolve => {
                setTimeout(_=>{
                    resolve('zMouse')
                }, 1000)
            })
        }).then(val => {
            console.log('z', val);
        });


    </script>
</body>
</html>